home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0034_Controlling Form Maximization.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-22  |  1.6 KB  |  55 lines

  1.  
  2. Okay, its late, and I've been playing with Delphi.  I just wrote out a
  3. simple little program that will allow you to control the size of a form when 
  4. its maximized.  It does this in such a way as to remove the flickering that 
  5. you see if you've been adjusting the size via the resize event.  Basically, 
  6. this code traps the wm_getminmaxinfo message. To use this style form instead 
  7. of the Delphi standard, simply compile the following text pascal file into a 
  8. DCU. In then replace occurences of TForm with TMaxForm and add (if you
  9. called the pascal file maxform.pas) maxform to your uses clause.  Here 
  10. now is the short program:
  11.  
  12. unit Maxform;
  13.  
  14. interface
  15.  
  16. uses
  17.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  18.   Forms, Dialogs;
  19.  
  20. type
  21.   TMaxForm = class(TForm)
  22.   private
  23.     { Private declarations }
  24.     fmh, fmw, fml, fmt : word;
  25.     procedure mymax(var m: TWMGETMINMAXINFO);
  26.               message wm_getminmaxinfo;
  27.   published
  28.     property maxheight : word read mh write mh;
  29.     property maxwidth  : word read mw write mw;
  30.     property maxleft   : word read ml write ml;
  31.     property maxtop    : word read mt write mt;
  32.     constructor create(AOwner : TComponent); override;
  33.   end;
  34.  
  35. implementation
  36.  
  37. procedure TMaxForm.mymax(var m : TWMGETMINMAXINFO);
  38. begin
  39. m.minmaxinfo^.ptmaxsize.x := fmw;
  40. m.minmaxinfo^.ptmaxsize.y := fmh;
  41. m.minmaxinfo^.ptmaxposition.x := fml;
  42. m.minmaxinfo^.ptmaxposition.y := fmt;
  43. end;
  44.  
  45. constructor TMaxForm.create(Aowner : TComponent);
  46. begin
  47. fmw := screen.width;
  48. fmh := screen.height;
  49. fmt := 0;
  50. fml := 0;
  51. inherited create(aowner);
  52. end;
  53. end.
  54.  
  55.